home *** CD-ROM | disk | FTP | other *** search
- /*============================================================
-
- Cel & Rotate sample program
-
- ============================================================*/
- #include "N_Library.h"
-
- short Data_Rsrc = 0;
- long total_step = 0;
- long wait;
- short i,r=0;
- short x[128];
- short y[128];
- short rt[128];
- short sp[128];
-
- void main(void)
- {
- WindowPtr window;
- short p,xx,yy;
-
- ToolboxInit();
- ColorCheck();
- HideMenuBar();
- window = GetNewWindow (128,nil,(WindowPtr)-1L );
- N_Window_Set(window,-(window->portBits.bounds.left),-(window->portBits.bounds.top),640,480);
- Open_Resource_File(128,1,&Data_Rsrc);
- N_Sp_Make(640,480); //initialize sprite offscreen
- N_Cel_Make2(640,480); //keep cel plane work area
- HideCursor();
- N_Pict_Draw(128,0,0,(GrafPtr)Main_Window,true);
- N_Sprite_Set(130,0,32,32,0,1,1,1); //Sp 0(rotation mode)
- N_Sprite_Set(201,1,32,32,0,1,1,0); //Sp 1
- N_Sprite_Set(202,2,32,32,0,1,1,0); //Sp 2
- Delay(60,&wait);
- Close_Resource_File(&Data_Rsrc);
-
- for (i=0;i!=128;i++)
- {
- x[i] = GetRandom(0,640-48);
- y[i] = GetRandom(0,480-48);
- sp[i] = GetRandom(2,5)*2;
- rt[i] = 0;
- }
- do
- {
- if (GetRandom(0,1)==0)
- {
- N_Sp_Put(0x80000000+1,GetRandom(0,19)*32,GetRandom(0,14)*32);
- }
- else
- {
- N_Sp_Put(0x80000000+2,GetRandom(0,19)*32,GetRandom(0,14)*32);
- }
-
- if (total_step<128)
- {
- for (i=0;i!=24;i++)
- {
- N_Cel_2D_Rot_Put(i,0x80000000,x[i],y[i],x[i]+16,y[i]+16,rt[i]);
- x[i] = x[i] + sp[i];
- if (x[i]>640)
- {
- x[i] = -64;
- y[i] = GetRandom(0,480)-48;
- }
- }
- }
-
- if (total_step>=128 && total_step<256)
- {
- for (i=0;i!=24;i++)
- {
- N_Cel_2D_Rot_Put(i,0x80000000,x[i],y[i],320,240,r);
- }
- r+=8;
- }
-
- if (total_step>=256 && total_step<384)
- {
- for (i=0;i!=24;i++)
- {
- N_Cel_2D_Rot_Put(i,0x80000000,x[i],y[i],300,250,r);
- x[i] = x[i] + sp[i];
- if (x[i]>640)
- {
- x[i] = -64;
- y[i] = GetRandom(0,480)-48;
- }
-
- }
- r-=8;
- }
-
- if (total_step>=384 && total_step<511)
- {
- for (i=0;i!=24;i++)
- {
- rt[i] = x[i]*4;
- N_Cel_2D_Rot_Put(i,0x80000000,x[i],y[i],x[i]+16,y[i]+16,rt[i]);
- x[i] = x[i] + sp[i];
- if (x[i]>640)
- {
- x[i] = -64;
- y[i] = GetRandom(0,480)-48;
- }
- }
- }
-
- if (total_step == 511)
- {
- total_step =0;
- r = 0;
- }
-
- N_Cel_Loop2(0,0);
- total_step++;
- }
- while (!Button());
-
- ShowMenuBar();
- ShowCursor();
- FlushEvents( everyEvent, 0 );
- ColorRevert();
- }
-
-
-
-